﻿using Grow.Domain.EventBus;

namespace Grow.Domain.Object
{
    // <summary>
    /// 聚合根
    /// </summary>
    public interface IAggregateRoot : IEntity
    {
        /// <summary>
        /// 获取领域事件集合
        /// </summary>
        IEnumerable<IDomainEvent> GetDomainEvents();

        /// <summary>
        /// 添加领域事件
        /// </summary>
        /// <param name="domainEvent">领域事件</param>
        void AddDomainEvent(IDomainEvent domainEvent);

        /// <summary>
        /// 移除领域事件
        /// </summary>
        /// <param name="domainEvent">领域事件</param>
        void RemoveDomainEvent(IDomainEvent domainEvent);

        /// <summary>
        /// 清空领域事件
        /// </summary>
        void ClearDomainEvents();
    }
}
